package org.tony.spider.core.util;

import org.tony.common.http.Browser;

public final class SpiderHelper
{

  public static final Browser openBrowser()
  {
    Boolean proxyEnable = Boolean.valueOf(SpiderConfig.getInstance().getConfig("proxy-enable"));
    Browser browser = Browser.newInstance();
    if (browser != null)
    {
      if (proxyEnable)
      {
        String proxyHost = SpiderConfig.getInstance().getConfig("proxy-host");
        String proxtPort = SpiderConfig.getInstance().getConfig("proxy-port");
        if (proxyHost != null && proxtPort != null)
        {
          browser.setProxy(proxyHost, Integer.parseInt(proxtPort));
        }
      }
    }
    return browser;
  }
}
